<template>
  <div class="">
    <h3>注册</h3>
    <form action="" method="post">
      <input
        type="text"
        name="username"
        placeholder="用户名"
        v-model="username"
      />
      <input
        type="text"
        name="password"
        placeholder="密码"
        v-model="password"
      />
      <input type="submit" value="注册" @click.prevent="register" />
    </form>
  </div>
</template>

<script>
import { reqRegisterAPI } from "../../api/user";
// import { setToken } from "../../utils/auth"; //引入token
export default {
  data() {
    return {
      username: "",
      password: "",
    };
  },
  computed: {},
  watch: {},

  methods: {
    async register() {
      console.log(11, this.username, this.password);
      const result = await reqRegisterAPI({
        username: this.username,
        password: this.password,
      });
      console.log(result);
    },
    // async onSubmit(values) {
    //   console.log("submit", values);
    //   //登录
    //   const result = await reqLoginAPI(values);
    //   console.log(result);
    //   if (result.code == "success") {
    //     //如果登录成功，把token存入cookie
    //     setToken(result.token);
    //     //存入vuex状态管理里面
    //     this.$store.commit("saveToken", result.token);
    //     //还要存入本地缓存，如何根据本地缓存，防止刷新后 vuex保存的token丢失
    //     localStorage.setItem("token", result.token);
    //     Toast.success("登录成功");
    //     // 登录成功跳转到个人页面
    //     this.$router.push({
    //       path: "/mine",
    //     });
    //   }
    // },
  },
  created() {},
  mounted() {},
  components: {},
};
</script>
<style scoped></style>
